package com.dingding.manager.modules.system.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.dingding.manager.common.beans.carinfo.CarBrandInfo;
import com.dingding.manager.common.beans.carinfo.CarModelInfo;
import com.dingding.manager.modules.system.service.CarTypeService;

/**
 * 
 * @Description: 车辆品牌获取
 * @author haoxiaojun
 * @date 2016年12月9日 下午6:10:42
 * @since V 2.5.7
 */
@Controller
@RequestMapping("/cartype/v1")
public class CarTypeController {
	  
	
	private Logger logger = LoggerFactory.getLogger(getClass());
	
	@Resource(name="carTypeService")
	private CarTypeService carTypeService;
	
	/**
	 * 
	* @Description: 获取所有车辆品牌
	* @author haoxiaojun 
	* @return RespResult<CarBrandInfo>
	* @date 2016年12月9日 下午6:11:06
	* @since V 2.5.7
	 */
	@RequestMapping(value = "/brand", method = { RequestMethod.POST })
	@ResponseBody
	public List<CarBrandInfo> getCarBrand(HttpServletRequest request, HttpServletResponse response) {
		
		List<CarBrandInfo> carBrandList = carTypeService.getCarBrand();

		return carBrandList;

	}
	
	/**
	 * 
	 * @Description: 根据品牌Id获取该品牌下的车型
	 * @author haoxiaojun
	 * @return RespResult<CarModelInfo>
	 * @date 2016年12月9日 下午6:11:39
	 * @since V 2.5.7
	 */
	@RequestMapping(value = "/model", method = { RequestMethod.POST })
	@ResponseBody
	public List<CarModelInfo> getCarModel(Integer id, HttpServletRequest request, HttpServletResponse response) {
		
		List<CarModelInfo> carModelList = carTypeService.getCarModel(id);
		
		return carModelList;

	}
	
	/**
	 * 
	* @Description: 根据车辆品牌模糊查询
	* @author haoxiaojun 
	* @return List<CarBrandInfo>
	* @date 2016年12月14日 下午3:42:04
	* @since V 2.5.7
	 */
	@RequestMapping(value = "/brandbykeys", method = { RequestMethod.POST })
	@ResponseBody
	public List<CarBrandInfo> getCarBrandByFirst(String keys, HttpServletRequest request, HttpServletResponse response) {
		
		List<CarBrandInfo> carBrandInfo = carTypeService.getCarBrandByFirst(keys);
		
		return carBrandInfo;

	}
}
